package cn.wolfcode.wolf2w.redis.service.impl;

import cn.wolfcode.wolf2w.redis.service.IRedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Service
public class RedisServiceImpl implements IRedisService {
    @Autowired
    private RedisTemplate redisTemplate;
    @Override
    public void saveRedis(String phone, String code) {
        redisTemplate.opsForValue().set(phone, code,5, TimeUnit.MINUTES);

    }
    @Override
    public String getRedis(String phone) {
        String code = (String) redisTemplate.opsForValue().get(phone);
        return code;
    }
}
